ostbuild: Drop down to Python 2.6
authorColin Walters <walters@verbum.org>
Tue, 21 Feb 2012 03:31:10 +0000 (22:31 -0500)
committerColin Walters <walters@verbum.org>
Tue, 21 Feb 2012 03:31:10 +0000 (22:31 -0500)
Hopefully this gets us working on RHEL6.

src/ostbuild/pyostbuild/builtin_autodiscover_meta.py
src/ostbuild/pyostbuild/builtin_chroot_compile_one.py
src/ostbuild/pyostbuild/builtin_compile_one.py

index 9e7c6ffd3efb7a915165faa7df3c7627afb6fe54..235927b5dd88193f66deedbb42c013a1afe37cca 100755 (executable)
@@ -24,6 +24,7 @@ import json
 from . import builtins
 from . import buildutil
 from .ostbuildlog import log, fatal
+from .subprocess_helpers import run_sync, run_sync_get_output
 
 class OstbuildAutodiscoverMeta(builtins.Builtin):
     name = "autodiscover-meta"
@@ -76,14 +77,13 @@ class OstbuildAutodiscoverMeta(builtins.Builtin):
         
     def _discover_branch_from_git(self):
         if os.path.isdir('.git'):
-            try:
-                try:
-                    ref = subprocess.check_output(['git', 'symbolic-ref', 'HEAD'], stderr=open('/dev/null', 'w'))
-                    return ref.replace('refs/heads/', '').strip()
-                except subprocess.CalledProcessError, e:
-                    return subprocess.check_output(['git', 'describe', '--tags', '--exact-match', 'HEAD']).strip()
-            except subprocess.CalledProcessError, e:
-                return None
+            devnull=open('/dev/null', 'w')
+            ref = run_sync_get_output(['git', 'symbolic-ref', 'HEAD'], stderr=devnull, none_on_error=True)
+            if ref is not None:
+                return ref.replace('refs/heads/', '').strip()
+            ref = run_sync_get_output(['git', 'describe', '--tags', '--exact-match', 'HEAD'], stderr=devnull, none_on_error=True)
+            if ref is not None:
+                return ref
         return None
     
 builtins.register(OstbuildAutodiscoverMeta)
index 43bbb53029e36336fa2e05361bfc57e496e53e0a..cfc18369ae3eb8a1b220408760d6d237923b8607 100755 (executable)
@@ -23,7 +23,7 @@ import json
 from . import builtins
 from . import buildutil
 from .ostbuildlog import log, fatal
-from .subprocess_helpers import run_sync
+from .subprocess_helpers import run_sync, run_sync_get_output
 
 class OstbuildChrootCompileOne(builtins.Builtin):
     name = "chroot-compile-one"
@@ -41,7 +41,7 @@ class OstbuildChrootCompileOne(builtins.Builtin):
         (args, rest_args) = parser.parse_known_args(argv)
 
         if args.meta is None:
-            output = subprocess.check_output(['ostbuild', 'autodiscover-meta'])
+            output = run_sync_get_output(['ostbuild', 'autodiscover-meta'])
             self.metadata = json.loads(output)
         else:
             f = open(args.meta)
@@ -67,8 +67,8 @@ class OstbuildChrootCompileOne(builtins.Builtin):
             shutil.rmtree(child_tmpdir)
         os.mkdir(child_tmpdir)
         
-        rev = subprocess.check_output(['ostree', '--repo=' + args.repo, 'rev-parse', args.buildroot])
-        rev=rev.strip()
+        rev = run_sync_get_output(['ostree', '--repo=' + args.repo, 'rev-parse', args.buildroot])
+        rev = rev.strip()
         
         self.metadata['buildroot'] = args.buildroot
         self.metadata['buildroot-version'] = rev
index cd2983dadd2a49f53d90a74a6da7ced93f257401..d7fbd94327af53b2f70b8ce2134d9f6d3102a7f8 100755 (executable)
@@ -26,7 +26,7 @@ import select,time
 
 from . import builtins
 from .ostbuildlog import log, fatal
-from .subprocess_helpers import run_sync
+from .subprocess_helpers import run_sync, run_sync_get_output
 
 PREFIX = '/usr'
 
@@ -100,7 +100,7 @@ class OstbuildCompileOne(builtins.Builtin):
         self.metadata = {}
 
         if self.ostbuild_meta is None:
-            output = subprocess.check_output(['ostbuild', 'autodiscover-meta'])
+            output = run_sync_get_output(['ostbuild', 'autodiscover-meta'])
             self.metadata = json.loads(output)
         else:
             f = open(self.ostbuild_meta)